<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of homepage
 *
 * @author sonUIT
 */
class Homepage extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->library("loadpage");
    }

    public function index() {
        $data = array();
        $lp = new loadpage();
        if (isset($_GET['matp'])) {
            $data['title'] = "Chi tiết sản phẩm";
            $lp->load(array("product_detail_view"), $data);
        } else {
            $data['title'] = "AIO Book Store online";
            $this->load->model('mproduct');
            $mproducts = new Mproduct();
            $data['products'] = $mproducts->GetAllProducts();
            $data['tacgias'] = array(array());
            $data['nxbs'] = array(array());
            $this->load->model("mtacgia");
             $this->load->model("mnhaxuatban");
             $nxb=new Mnhaxuatban();
            $tacgia = NEW Mtacgia();
            foreach ($data['products'] as $row) {
                $tacgia->GetByMatg($row["MATG"]);
                array_push($data['tacgias'], $tacgia->ToArray());
                $nxb->GetByManxb($row['MANXB']);
                array_push($data['nxbs'],$nxb->ToArray());
            }
            $lp->load(array("slideshow_view", "products_view"), $data);
        }
    }

}

?>
